﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FileClient
{
    public class Protocol
    {
        private static Protocol protocolInstance = null;
        private string UserName;

        public static Protocol Instance
        {
            get
            {
                if (protocolInstance == null)
                    protocolInstance = new Protocol();
                return protocolInstance;
            }
        }

        private string message;
        /*#############SERVER PROTOCOL STRINGS++++++++++++++++
         * Start by selecting the Server
         * $FRANK
         * now Add what follows 
         */


        /*##############FILE PROTOCOL STRINGS++++++++++++++++++++++
         *  Define what catergoy
         *  "FILE"
         * Define Function
         *      UPLOAD  Upload a file
         *      DOWNLOAD Download a File
         *EG
         *  To Send a File use the string 
         *  $FRANK,FILE,UPLOAD,<PARAMERTERS>,
         *  
         */


        /*##############USER PROTOCOL STRINGS++++++++++++++++++++++
         *  Define what catergoy
         *  "USER"
         * Define Function
         *      CREATE  Create a User
         *      GET     Get User Data
         *      DELETE  DELETE A USER
         */

        public void Login(string userName, string password)
        {
            message = "$FRANK,USER,LOGIN," + userName + "," + password + ",";
            Network.Instance.sendMessage(message);
            UserName = userName;
        }

        public void SendFile(string filePath, string fileName)
        {
            message = "$FRANK,FILE,UPLOAD,";
            Network.Instance.sendfile(message, filePath, fileName);
        }

        public void CreateUser(string username, string fname, string lname, string pass)
        {
            message = "$FRANK,USER,CREATE," + username + "," + fname + "," + lname + "," + pass + ",";
            Network.Instance.sendMessage(message);
        }

        public void Disconnect()
        {
            message = "$FRANK,CLIENT,DIS," + UserName + ",";
            Network.Instance.sendMessage(message);
        }

        public void messageHandler(string message)
        {

        }
    }
}
